<template>
  <div>
    <el-card :bordered="false" shadow="never" class="ivu-mt" :body-style="{ padding: 0 }">
      <div class="padding-add">
        <el-form
          ref="userFrom"
          :model="userFrom"
          label-width="80px"
          label-position="right"
          @submit.native.prevent
          inline
        >
          <div class="acea-row search-form" v-if="!collapse">
            <div>
              <el-form-item label="订单编号:" label-for="searchOrderNo">
                <el-input
                  clearable
                  placeholder="请输入内容"
                  v-model="userFrom.searchOrderNo"
                  class="form_content_width"
                />
              </el-form-item>
              <el-form-item label="产品名称：" label-for="productName">
                <el-input
                  clearable
                  placeholder="请输入内容"
                  v-model="userFrom.productName"
                  class="form_content_width"
                />
              </el-form-item>

              <el-form-item label="产品ID:" label-for="pId">
                <el-input clearable placeholder="请输入内容" v-model="userFrom.pId" class="form_content_width" />
              </el-form-item>
              <el-form-item label="用户昵称：" label-for="nick_name">
                <el-input clearable placeholder="请输入内容" v-model="userFrom.nickName" class="form_content_width" />
              </el-form-item>
            </div>
            <el-form-item class="search-form-sub">
              <el-button type="primary" @click="userSearchs">搜索</el-button>
              <el-button class="ResetSearch" @click="reset('userFrom')">重置</el-button>
              <a class="ivu-ml-8 font12 ml10" @click="collapse = !collapse">
                <template v-if="!collapse"> 展开 <i class="el-icon-arrow-down" /> </template>
                <template v-else> 收起 <i class="el-icon-arrow-up" /> </template>
              </a>
            </el-form-item>
          </div>
          <div v-if="collapse" class="acea-row search-form">
            <div class="search-form-box">
              <el-form-item label="订单编号:" label-for="searchOrderNo">
                <el-input
                  clearable
                  placeholder="请输入内容"
                  v-model="userFrom.searchOrderNo"
                  class="form_content_width"
                />
              </el-form-item>
              <el-form-item label="产品名称：" label-for="productName">
                <el-input
                  clearable
                  placeholder="请输入内容"
                  v-model="userFrom.productName"
                  class="form_content_width"
                />
              </el-form-item>

              <el-form-item label="产品ID:" label-for="pId">
                <el-input clearable placeholder="请输入内容" v-model="userFrom.pId" class="form_content_width" />
              </el-form-item>
              <el-form-item label="用户昵称：" label-for="nick_name">
                <el-input clearable placeholder="请输入内容" v-model="userFrom.nickName" class="form_content_width" />
              </el-form-item>

              <el-form-item label="创建时间:" label-for="date_time">
                <el-date-picker
                  v-model="userFrom.dateTime"
                  type="daterange"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                >
                </el-date-picker>
              </el-form-item>
            </div>

            <el-form-item class="search-form-sub">
              <el-button type="primary" label="default" @click="userSearchs">搜索</el-button>
              <el-button class="ResetSearch" @click="reset('userFrom')">重置</el-button>
              <a class="ivu-ml-8 font12 ml10" @click="collapse = !collapse">
                <template v-if="!collapse"> 展开 <i class="el-icon-arrow-down" /> </template>
                <template v-else> 收起 <i class="el-icon-arrow-up" /> </template>
              </a>
            </el-form-item>
          </div>
        </el-form>
      </div>
    </el-card>
    <el-card :bordered="false" shadow="never" class="ivu-mt mt16" :body-style="{ padding: '0 20px 20px' }">
      <el-tabs v-model="userFrom.user_type" @tab-click="onClickTab">
        <el-tab-pane :label="item.name" :name="item.type" v-for="(item, index) in headeNum" :key="index" />
      </el-tabs>
      <el-table
        :data="userLists"
        class="mt16"
        ref="table"
        highlight-current-row
        v-loading="loading"
        empty-text="暂无数据"
        no-filtered-userFrom-text="暂无筛选结果"
        @sort-change="sortChanged"
        @select="handleSelectRow"
        @select-all="handleSelectAll"
      >
        <el-table-column label="订单编号" width="150">
          <template slot-scope="scope">
            <span>{{ scope.row.order_no }}</span>
          </template>
        </el-table-column>
        <el-table-column label="产品信息" width="630">
          <template slot-scope="scope">
            <div class="p-box" v-for="(option, index) in scope.row.product" :key="index">
              <div class="tabBox2_img" v-viewer>
                <img v-lazy="imgOssUrl + option.cover_image" />
              </div>
              <div class="w200">
                {{ option.title }}
              </div>
              <div class="w150">
                <div>型号</div>
                {{ option.model }}
              </div>
              <div class="w150">
                <div>价格</div>
                {{ option.market_price }}
              </div>
              <div class="w150">
                <div>数量</div>
                {{ option.quantity }}
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="买家信息" min-width="150">
          <template slot-scope="scope">
            <div>{{ scope.row.user_nick }}</div>
            <div class="pt10">{{ scope.row.user_email }}</div>
          </template>
        </el-table-column>
        <el-table-column label="订单金额" width="160">
          <template slot-scope="scope">
            <span>{{ scope.row.payable_amount }}</span>
          </template>
        </el-table-column>
        <el-table-column label="件数" width="80">
          <template slot-scope="scope">
            <span>{{ scope.row.total_quantity }}</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" width="120">
          <template slot-scope="scope">
            <span>{{ statusText(scope.row.order_status) }}</span>
          </template>
        </el-table-column>

        <el-table-column label="创建时间" prop="now_money" width="500" :sortable="true">
          <template slot-scope="scope">
            <div>{{ scope.row.create_time }}</div>
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" width="320">
          <template slot-scope="scope">
            <template>
              <a @click="userDetail(scope.row)">详情</a>

              <el-divider direction="vertical"></el-divider>
              <a @click="userDetail(scope.row)">跟进记录</a>
              <el-divider direction="vertical"></el-divider>
              <a @click="userDetail(scope.row)">备注</a>
              <el-divider direction="vertical"></el-divider>
              <a @click="userDetail(scope.row)">取消</a>
              <el-divider direction="vertical"></el-divider>
              <a @click="userDetail(scope.row)">意向合同修改</a>
            </template>
          </template>
        </el-table-column>
      </el-table>
      <div class="acea-row row-right page">
        <pagination
          v-if="total"
          :total="total"
          :page.sync="userFrom.page"
          :limit.sync="userFrom.limit"
          @pagination="pageChange"
        />
      </div>
    </el-card>
  </div>
</template>
<script>
import { getShopAuth, getProvinceFn, getComOrderList } from '@/api/all';
export default {
  name: '',
  components: {},
  data() {
    let self = this;
    return {
      userFrom: {
        searchOrderNo: '',
        productName: '',
        pId: '',
        nickName: '',
        dateTime: '',
        user_type: '',
        page: 1,
        limit: 10,
      },

      collapse: false,
      selectLabelShow: false,
      selectDataLabel: [],
      address: '',
      headeNum: [
        { type: '', name: '全部' },
        { type: '1', name: '待确认' },
        { type: '2', name: '待支付' },
        { type: '3', name: '待发货' },
        { type: '4', name: '待收货' },
        { type: '5', name: '已完成' },
        { type: '6', name: '已取消' },
      ],
      userLists: [],
      total: 0,
    };
  },
  watch: {},
  computed: {},
  async created() {
    console.log(this.imgOssUrl);
    const res = await getComOrderList({
      status: 1,
      page: 1,
      size: 10,
      shop_type: -1,
      order_status: -1,
    });

    this.userLists = res.data.data;
    this.total = res.data.total;
  },
  mounted() {},
  methods: {
    statusText(order_status) {
      switch (order_status) {
        case 0:
          return '待确认';
        case 1:
          return '待支付';
        case 2:
          return '待发货';
        case 4:
          return '待收货';
        case 8:
          return '已完成';
        default:
          return '已取消';
      }
    },
    openSelectLabel() {
      this.selectLabelShow = true;
    },

    async provinceFn(pid) {
      const res = await getProvinceFn({ pid: pid });
      return res.data;
    },

    //地址选择
    handleChange(label) {
      this.address = label;
      console.log(this.address);
    },

    userSearchs() {
      console.log(this.userFrom);
    },
    reset() {
      this.userFrom = {
        userName: '',
        userEmail: '',
        userPhone: '',
        dateTime: '',
        nickName: '',
      };
    },
    pageChange() {},
  },
};
</script>
<style scoped lang="scss">
::v-deep .el-tabs__item {
  height: 54px !important;
  line-height: 54px !important;
}
.picBox {
  display: inline-block;
  cursor: pointer;

  .upLoad {
    width: 58px;
    height: 58px;
    line-height: 58px;
    border: 1px dotted rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.02);
    font-size: 24px;
    font-weight: 500;
  }

  .pictrue {
    width: 60px;
    height: 60px;
    border: 1px dotted rgba(0, 0, 0, 0.1);
    margin-right: 10px;

    img {
      width: 100%;
      height: 100%;
    }
  }
}

.userFrom {
  ::v-deep .ivu-form-item-content {
    margin-left: 0px !important;
  }
}

.userAlert {
  margin-top: 20px;
}

.userI {
  color: var(--prev-color-primary);
  font-style: normal;
}

img {
  height: 36px;
  display: block;
}

.tabBox2_img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;

  img {
    width: 100%;
    height: 100%;
  }
}
.tabBox_img-box {
  display: flex;
}
.tabBox_img {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;

  img {
    width: 100%;
    height: 100%;
  }
}

.tabBox_tit {
  width: 60%;
  font-size: 12px !important;
  margin: 0 2px 0 10px;
  letter-spacing: 1px;
  padding: 5px 0;
  box-sizing: border-box;
}

.modelBox {
  ::v-deep .ivu-modal-body {
    padding: 0 16px 16px 16px !important;
  }
}

.vipName {
  color: #dab176;
}

.listbox {
  ::v-deep .ivu-divider-horizontal {
    margin: 0 !important;
  }
}

.labelInput {
  width: 250px;
  border: 1px solid #dcdee2;
  padding: 0 15px;
  border-radius: 5px;
  min-height: 30px;
  cursor: pointer;
  font-size: 12px;
  .span {
    color: #c5c8ce;
  }

  .ivu-icon-ios-arrow-down {
    font-size: 14px;
    color: #808695;
  }
}

.demo-drawer-footer {
  width: 100%;
  position: absolute;
  bottom: 0;
  left: 0;
  border-top: 1px solid #e8e8e8;
  padding: 10px 16px;
  text-align: right;
  background: #fff;
}
.search-form {
  display: flex;
  justify-content: space-between;
  .search-form-box {
    display: flex;
    flex-wrap: wrap;
    flex: 1;
  }
}
.search-form-sub {
  display: flex;
}

.w200 {
  width: 200px;
}

.w150 {
  width: 200px;
}

.p-box {
  display: flex;
  align-items: center;
}
</style>

